<?php

namespace App\Http\Requests;

use Dingo\Api\Http\FormRequest;

class Request extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $action = explode('@', $this->route()->getAction()["uses"]);

        $method = $action[1].'Validation';

        return $this->$method();
    }

    /**
     * 自定义提示消息.
     *
     * @return array
     */
    public function messages()
    {
        return [
            'captcha_code.required' => '图形二维码不可为空',
            'captcha_key.required' => '缺少必要参数',
            'mobile.required' => '手机号不可以为空',
            'mobile.unique' => '手机号已注册',
        ];
    }
}
